#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
//	freopen("candy.in","r",stdin);
//	freopen("candy.out","w",stdout);
    long long n,l,r,ans;
    cin>>n>>l>>r;
	if(n<l){
		cout<<n-1;
		return 0;
	} 
	for(int i=l;i<=r;i++){
		ans=max(i%n,ans);
	}	
    cout<<ans;
    return 0;
}
